-
Notifications
You must be signed in to change notification settings - Fork 745
/
ModuleMessage.cs
115 lines (100 loc) · 4.32 KB
/
ModuleMessage.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information
namespace DotNetNuke.UI.Skins.Controls
{
using System;
using System.Diagnostics.CodeAnalysis;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNetNuke.Services.Exceptions;
/// <summary></summary>
public class ModuleMessage : SkinObjectBase
{
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Breaking change")]
protected Panel dnnSkinMessage;
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Breaking change")]
protected Label lblHeading;
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Breaking change")]
protected Label lblMessage;
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Breaking change")]
protected Control scrollScript;
public enum ModuleMessageType
{
GreenSuccess = 0,
YellowWarning = 1,
RedError = 2,
BlueInfo = 3,
}
/// <summary>Gets a value indicating whether check this message is shown as page message or module message.</summary>
public bool IsModuleMessage
{
get
{
return this.Parent.ID == "MessagePlaceHolder";
}
}
public string Text { get; set; }
public string Heading { get; set; }
public ModuleMessageType IconType { get; set; }
public string IconImage { get; set; }
/// <summary>
/// The Page_Load server event handler on this page is used
/// to populate the role information for the page.
/// </summary>
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
try
{
var strMessage = string.Empty;
// check to see if a url
// was passed in for an icon
if (!string.IsNullOrEmpty(this.IconImage))
{
strMessage += this.Text;
this.dnnSkinMessage.CssClass = "dnnFormMessage dnnFormWarning";
}
else
{
switch (this.IconType)
{
case ModuleMessageType.GreenSuccess:
strMessage += this.Text;
this.dnnSkinMessage.CssClass = "dnnFormMessage dnnFormSuccess";
break;
case ModuleMessageType.YellowWarning:
strMessage += this.Text;
this.dnnSkinMessage.CssClass = "dnnFormMessage dnnFormWarning";
break;
case ModuleMessageType.BlueInfo:
strMessage += this.Text;
this.dnnSkinMessage.CssClass = "dnnFormMessage dnnFormInfo";
break;
case ModuleMessageType.RedError:
strMessage += this.Text;
this.dnnSkinMessage.CssClass = "dnnFormMessage dnnFormValidationSummary";
break;
}
}
this.lblMessage.Text = strMessage;
if (!string.IsNullOrEmpty(this.Heading))
{
this.lblHeading.Visible = true;
this.lblHeading.Text = this.Heading;
}
}
catch (Exception exc)
{
Exceptions.ProcessModuleLoadException(this, exc, false);
}
}
/// <inheritdoc/>
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
// set the scroll js only shown for module message and in postback mode.
this.scrollScript.Visible = this.IsPostBack && this.IsModuleMessage;
}
}
}